Skip to content

XCSP3 (competition) support #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft

Conversation

Dekker1
Copy link
Contributor

@Dekker1 Dekker1 commented May 12, 2025

This PR track the implementation of XCSP3 support. The goal is to support enough of the format to compete in the XCSP3 challenge.

General Tasks

  • Change the name of the executable from fzn-huub to huub, where the crate will be renamed from fzn-huub to huub-cli.
  • Hide Model/Solver extraction methods from FlatZinc and Xcsp3Instance behind flatzinc and xcsp3 feature flags in huub.
  • Generalize the extracted data based for running instances in a way that works both for FlatZinc and XCSP3.
    • Before merging, it would be nice to implement shared version versions of Output and Goal objects that could directly be output from the from_X extraction methods.
    • Can we generalize the tracing variable registration methods, or will we have to specialize the code for each?
  • Implement XCSP3 competition conforming output.
  • Test the system using existing XCSP3 (competition) instances. (Is there a way to use the challenge infrastructure?)

xcsp3-serde Tasks

  • Implement the parsing of meta constraints
    • group
  • Implement flattening methods to allow solver the use of relevant constraints without placeholders.

Constraint support (as quoted from the competition call)>

  • Constraint extension
    This constraint is described in Section 4.1.1.2 in [BLAP21a]. Competition restrictions:
    1. Compressed tables (i.e., tables with compressed tuples) and smart tables are not
      accepted. However, do note that starred (or short) tables (i.e., tables with tuples containing ’*’) are accepted, as in 2019.
    2. Empty Tables (i.e., tables with 0 support or 0 conflict) are not accepted.
      Note that unary, binary and n-ary extensional constraints are accepted.
  • Constraint regular
    This constraint is described in Section 4.1.2.1 in [BLAP21a]. Competition restrictions:
    1. The automaton on which is based the constraint must be deterministic.
  • Constraint mdd
    This constraint is described in Section 4.1.2.3 in [BLAP21a]. Competition restrictions:
    1. There must be at least one path from the root node to the terminal node.
    2. In , the root note is given by the first item of the first transition.
  • Constraint allDifferent
    This constraint is described in Section 4.1.3.1 in [BLAP21a]. Competition restrictions:
    1. If present, the element only contains one (integer) value.
    2. Restricted forms (obtained by using the attribute restriction) are not accepted.
      In addition to the basic form of allDifferent, the advanced form allDifferent-matrix
      described in Section 7.2.1 in [BLAP21a] is accepted.
      Also, handling view extensions is authorized for the basic form of allDifferent. It means that instead of a list of variables inside the element , it is possible to have a list of integer expressions (trees). This is shown at the end of Section 4.1.3.1 in [BLAP21a]. Competition restriction:
    3. For the basic form of allDifferent, the element contains either only variables
      or only integer expressions (trees). It means that it is not possible to mix both forms.
  • Constraint allEqual
    This constraint is described in Section 4.1.3.2 in [BLAP21a]. Compared to 2019, handling
    view extensions is authorized for allEqual. It means that instead of a list of variables inside the element , it is possible to have a list of integer expressions (trees). There is no competition restriction for this constraint.
  • Constraint ordered
    This constraint is described in Section 4.1.3.4 in [BLAP21a]. Competition restrictions:
    1. The compact form, obtained by using the attribute case, is not accepted.
      As in 2019, note that it is now possible to deal with an element .
  • Constraint sum
    This constraint is described in Section 4.1.4.1 in [BLAP21a]. Competition restrictions:
    1. The condition is such that either the operator must be relational (i.e., must be in {lt,le,gt,ge,eq,ne}) and the (right) operand must be a value or a variable, or the operator must necessarily be in and the (right) operand must be an integer interval; See Section 1.5 in [BLAP21a].
      Also, handling view extensions is authorized for sum. It means here that instead of a list of variables inside the element , it is possible to have a list of integer expressions (trees).
      This is shown at the end of Section 4.1.4.1 in [BLAP21a]. Competition restriction:
    2. The element contains either only variables or only integer expressions (trees). It means that it is not possible to mix both forms.
  • Constraint count
    This constraint is described in Section 4.1.4.2 in [BLAP21a]. Competition restrictions:
    1. The element can only contain (integer) values.
    2. The condition is such that either the operator must be relational (i.e., must be in
      {lt,le,gt,ge,eq,ne}) and the (right) operand must be a value or a variable, or the operator must necessarily be in and the (right) operand must be an integer interval; See
      Section 1.5 in [BLAP21a].
      Compared to 2019, handling view extensions is authorized for count. It means here that instead of a list of variables inside the element , it is possible to have a list of integer expressions (trees).
  • Constraint nValues
    This constraint is described in Section 4.1.4.3 in [BLAP21a]. Competition restrictions:
    1. If present, the element only contains one (integer) value.
    2. The condition is such that either the operator must be eq and the (right) operand must be a value or a variable, or the operator is gt and the (right) operand is 1.
    3. Restricted forms (obtained by using the attribute restriction) are not accepted.
      Not that it is possible to deal with the special case where the condition is composed of the operator gt and the (right) operand is the value 1, which corresponds to the global constraint notAllEqual. Compared to 2019, handling view extensions is authorized for nValues.
      It means here that instead of a list of variables inside the element , it is possible to have a list of integer expressions (trees).
  • Constraint cardinality
    This constraint is described in Section 4.1.4.4 in [BLAP21a]. Competition restrictions:
    1. The element can only contain (integer) values.
    2. Restricted forms (obtained by using the attribute restriction) are not accepted.
  • Constraint maximum
    This constraint is described in Section 4.1.5.1 in [BLAP21a]. Competition restrictions:
    1. The condition is such that the operator must necessarily be eq and the (right) operand must be a value or a variable.
    2. The element , used for the variant <arg_max>, is not accepted.
  • Constraint minimum
    This constraint is described in Section 4.1.5.2 in [BLAP21a]. Competition restrictions:
    1. The condition is such that the operator must necessarily be eq and the (right) operand must be a value or a variable.
    2. The element , used for the variant <arg_min>, is not accepted.
  • Constraint element
    This constraint is described in Section 4.1.5.3 in [BLAP21a]. Competition restrictions:
    1. The optionnal attribute startIndex, if present, is necessarily equal to 0.
    2. The attribute rank, whose default value is "any", cannot be present.
      As in 2019, it is possible to have a list of values (instead of variables) inside . This is presented in Section 4.1.5.3 in [BLAP21a].
      Compared to 2019, the advanced form element-matrix described in Section 7.2.3 in [BLAP21a] is accepted.
  • Constraint channel
    This constraint is described in Section 4.1.5.4 in [BLAP21a]. Competition restrictions:
    1. Restricted forms (obtained by using the attribute restriction) are not accepted.
      As in 2019, note that for the form of channel involving two lists, it is possible that these two lists have different sizes. This is discussed at the top of Page 79 in Section 4.1.5.4 in [BLAP21a].
  • Constraint noOverlap
    This constraint is described in Section 4.1.6.2 in [BLAP21a]. Competition restrictions:
    1. In case the element contains (integer) values, whatever is the dimension, the value 0 is not accepted.
  • Constraint cumulative
    This constraint is described in Section 4.1.6.3 in [BLAP21a]. Competition restrictions:
    1. The element is not accepted.
    2. The variant, using , is not accepted.
  • Constraint instantiation
    This constraint is described in Section 4.1.8.2 in [BLAP21a]. There is no competition restriction for this constraint.
  • Constraint circuit
    This constraint is described in Section 4.1.7.1 in [BLAP21a]. Competition restrictions:
    1. The optionnal attribute startIndex, if present, is necessarily equal to 0.
    2. The element cannot be present.
  • Meta-Constraint slide
    This meta-constraint is described in Section 8.1 in [BLAP21a]. Competition restrictions:
    1. Only one element is accepted.
    2. The constraint template must be of form or .
  • Constraint precedence
    This constraint is described in Section 4.1.3.5 in [BLAP22]. Competition restrictions:
    • the attribute covered will not be used (and so, never present in instances used for the 2023 competition)
  • Constraint knapsack
    This constraint is described in Section 4.1.6.5 in [BLAP22]. Competition restrictions:
    • none
      This constraint can be very easily decomposed.
  • Constraint binPacking
    This constraint is described in Section 4.1.6.4 in [BLAP22]. Competition restrictions:
    • the general form will not be used (only the first three forms as described in Section
      4.1.6.4)
      This constraint can be easily decomposed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant